<style lang="scss" scoped>
</style>

<template>
    <div class="mshop-scroll">
        <slot></slot>
    </div>
</template>

<script>
    import ScrollerFactory from 'lib/scroller'

    export default {
        props: {
            action: Function,
            bottom_action: Function,
        },
        events: {
            top () {
                this.scroller.top();
            },
            cancel () {
                this.scroller.cancel();
            },
            reset () {
                this.scroller.reset();
            },
            scrollIntoView ($el, slient) {
                this.scroller.scrollIntoView($el, slient);
            }
        },
        data () { return {scroller: false}},
        ready () {
            this.scroller = new ScrollerFactory(this.$el);

            if (this.action) {
                this.scroller.listen(this.action);
            }

            if (this.bottom_action) {
                this.scroller.listen(this.bottom_action, 'bottom');
            }
        }
    }
</script>
